{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pycuda.gpuarray as gpuarray\n",
    "import pycuda.cumath as cmath\n",
    "import pycuda.driver as cuda\n",
    "import pycuda.autoinit\n",
    "import numpy as np\n",
    "import cv2 as cv\n",
    "import math\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "I = cv.imread('/home/nvidia-mm/Workspace/frame_diff_py/lena.jpg',cv.IMREAD_COLOR)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I_Ori_Bytes: 196608\n",
      "Shape: (256, 256, 3)   Bytes: 786432   Size: 196608\n"
     ]
    }
   ],
   "source": [
    "print 'I_Ori_Bytes:',I.nbytes\n",
    "I = I.astype(np.float32)\n",
    "I_gpu = cuda.mem_alloc(I.nbytes)\n",
    "I_shape = I.shape\n",
    "I_bytes = I.nbytes\n",
    "I_size = I.size\n",
    "print 'Shape:',I_shape,' ','Bytes:',I_bytes,' ','Size:',I_size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2, 3)   6   6   5\n",
      "(2, 3)   6   24   5.0\n",
      "(2, 3)   6   48   5.0\n"
     ]
    }
   ],
   "source": [
    "I=np.array([[1,2,3],[4,5,6]],dtype=np.uint8)\n",
    "print I.shape, ' ', I.size, ' ',I.nbytes, ' ',I[1][1]\n",
    "B=I.astype(np.float32)\n",
    "print B.shape, ' ', B.size, ' ',B.nbytes, ' ',B[1][1]\n",
    "C=I.astype(np.float64)\n",
    "print C.shape, ' ', C.size, ' ',C.nbytes, ' ',C[1][1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
